package com.type.service;

import java.util.ArrayList;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.type.dao.AdminManageBoardDAO;
import com.type.vo.AdminManageBoardVO;
import com.type.vo.ListAdminManageBoardVO;
import com.type.vo.PagingDTO;

@Service("TypeNineService")
public class TypeNineService {
	@Resource(name="AdminManageBoardDAO")
	private AdminManageBoardDAO dao;
	
	public AdminManageBoardVO selectOneAdminBoardByNo(int no){
		return  dao.selectAdminBoardByNo(no);	// 게시판 빈객체 리턴
	}
	
	public String deleteAdminBoardByNo(int no){
		String name = selectOneAdminBoardByNo(no).getBoardName();
		dao.deleteAdminBoardByNo(no);
		return name;	//게시판명 리턴
	}
	
	public AdminManageBoardVO updateAdminBoard(AdminManageBoardVO boardVO){
		dao.updateAdminBoard(boardVO);
		return selectOneAdminBoardByNo(boardVO.getBoardNo());		//게시판 객체 리턴
	}
	
	public String insertAdminBoard(AdminManageBoardVO boardVO){
		boardVO.setBoardNo(dao.selectBoardNo());
		dao.insertAdminBoard(boardVO);
		return boardVO.getBoardName();	//게시판명 리턴
	}
	
	public ListAdminManageBoardVO selectAllAdminBoardByPage(int page){
		ArrayList<AdminManageBoardVO> boardlist = dao.selectAdminBoardAllListByPaging(page);
		int total = dao.getTotalCountOfBoard();
		PagingDTO paging = new PagingDTO(total, page);
		ListAdminManageBoardVO listAdminBoard = new ListAdminManageBoardVO(boardlist,paging );
		return listAdminBoard;
	}
	
	public ListAdminManageBoardVO searchAdminNameByPage(int page, String boardType, String text){
		ArrayList<AdminManageBoardVO> boardlist = dao.searchAdminNameByPaging(page, boardType, text);
		int total = boardlist.size();
		PagingDTO paging = new PagingDTO(total, page);
		ListAdminManageBoardVO listAdminBoard = new ListAdminManageBoardVO(boardlist,paging );
		return listAdminBoard;
	}

	public ListAdminManageBoardVO SearchAdminBoardNameByPage(int page,	String boardType, String boardName) {
		ArrayList<AdminManageBoardVO> boardlist = dao.searchBoardNameByPaging(page, boardType, boardName);
		int total = boardlist.size();
		PagingDTO paging = new PagingDTO(total, page);
		ListAdminManageBoardVO listAdminBoard = new ListAdminManageBoardVO(boardlist,paging );
		return listAdminBoard;
	}
	
	
}
